_num = count _this;

_helo = _this select (_num-1);
_callsign = _this select 1;
_spwn = _this select 3;

//hint format ["%1",_this];

_paytar = [];
RUM_ASclick = false;

openMap [true,true];
for [{_n=1},{_n<=3},{_n=_n+1}] do {
	_mkrname = "";
	_type = "";
	_hint = "";
	switch (_n) do {
		case 1: {
			_mkrname = format ["%1target",_helo];
			_type = "Destroy";
			_hint = "Select Target Area for CAS";
		};
		case 2: {
			_mkrname = format ["%1ingress",_helo];
			_type = "mil_start";
			_hint = "Select Ingress Point";
		};
		case 3: {
			_mkrname = format ["%1egress",_helo];
			_type = "mil_end";
			_hint = "Select Egress Point";
		};
		default {
			hint "shit";	
		};
	};
	_asloc = createMarkerLocal [_mkrname, [0,0,0]];
	_asloc setMarkerShapeLocal "ICON";
	_mkrname setMarkerTypeLocal _type;
	_stgtar = "";
	if(_n == 1)then{_stgtar = format ["'%1' setMarkerPosLocal _pos,RUM_ASclick = [_pos] call ROEzone",_mkrname]}else{_stgtar = format ["'%1' setMarkerPosLocal _pos,RUM_ASclick = true",_mkrname]};	onMapSingleClick _stgtar;
	titleText [_hint, "PLAIN DOWN"];
	waitUntil {RUM_ASclick};
	onMapSingleClick "";
	if((_n == 2) or (_n == 3)) then {
		_mkrname2 = format ["%1target",_helo];
		_mkrname setMarkerDir ((getMarkerPos _mkrname2 select 0)-(getMarkerPos _mkrname select 0)) atan2 ((getMarkerPos _mkrname2 select 1)-(getMarkerPos _mkrname select 1));
	};
	RUM_ASclick = false;
};
titleFadeOut 0;
sleep 1;
openMap [false,false];

_pilot = driver _helo;
_grp = group _pilot;

_mkrnamepri = format ["%1target",_helo];
_pos1 = getpos player;
_pos2 = getMarkerpos _mkrnamepri;
_dis = (round ((_pos2 distance _pos1)/10))*10;
_dir = round (((_pos1 select 1)-(_pos2 select 1)) atan2 ((_pos1 select 0)-(_pos2 select 0)));
if(_dir < 0)then{_dir = _dir + 360};

["5line",[player,_pilot,_callsign,_dir,_dis]] execVM (RUM_PATH+"AHel\radiodialogs.sqf");
sleep 30;

for [{_n=1},{_n<=3},{_n=_n+1}] do {
	_mkrname = "";
	switch (_n) do {
		case 1: {
			_mkrname = format ["%1ingress",_helo];
		};
		case 2: {
			_mkrname = format ["%1target",_helo];
		};
		case 3: {
			_mkrname = format ["%1egress",_helo];
		};
		default {
			hint "shit";	
		};
	};
	if(_n==2)then {
		_wpAH=_grp addWaypoint [getMarkerpos _mkrname, 0];
		_wpAH setWaypointType "SAD";
		_wpAH setWaypointSpeed "FULL";
		_wpAH setWaypointCombatMode "RED";
		_wpAH setWaypointCompletionRadius 700;	
	} else {	
		_wpAH=_grp addWaypoint [getMarkerpos _mkrname, 0];
		_wpAH setWaypointType "MOVE";
		_wpAH setWaypointSpeed "NORMAL";
		_wpAH setWaypointCombatMode "BLUE";
		_wpAH setWaypointCompletionRadius 50;
	};
};

_station = format ["%1station",_helo];

fwp2=_grp addWaypoint [getMarkerpos _station, 0];
fwp2 setWaypointType "MOVE";
fwp2 setWaypointSpeed "NORMAL";
fwp2 setWaypointBehaviour "CARELESS";
fwp2 setWaypointCombatMode "BLUE";
fwp2 setWaypointCompletionRadius 50;

sleep 45;
waitUntil{(!alive _helo) or (((((getPos _helo select 0) - (getmarkerpos _station select 0))^2+((getPos _helo select 1) - (getmarkerpos _station select 1))^2)^0.5) <= 100)};

_mkrname1 = format ["%1ingress",_helo];
_mkrname2 = format ["%1target",_helo];
_mkrname3 = format ["%1egress",_helo];
deletemarkerLocal _mkrname1;
deletemarkerLocal _mkrname2;
deletemarkerLocal _mkrname3;

if(true)exitwith{};
